import "./index.scss";
import { useNavigate, useLocation } from "react-router-dom";

const StudentDetail = () => {
  //取数据
  const state = useLocation();
  console.log("state", state.state);

  //返回备案页面
  const navigate = useNavigate();
  const back = () => {
    navigate("/home/studentFiling");
  };

  //时间转换
  const toDub = (n: any) => (n < 10 ? "0" + n : "" + n);
  //年月日时分秒
  const toTime = (date: any) => {
    const oTime = new Date(date);
    return (
      oTime.getFullYear() +
      "-" +
      toDub(oTime.getMonth() + 1) +
      "-" +
      toDub(oTime.getDate()) +
      " " +
      toDub(oTime.getHours()) +
      ":" +
      toDub(oTime.getMinutes()) +
      ":" +
      toDub(oTime.getSeconds())
    );
  };
  //年月日
  const toDate = (date: any) => {
    const oDate = new Date(date);
    return (
      oDate.getFullYear() +
      "-" +
      toDub(oDate.getMonth() + 1) +
      "-" +
      toDub(oDate.getDate())
    );
  };

  return (
    <div className="student-detail">
      <div className="top">
        <div className="title" onClick={back}>
          学生管理
        </div>
        <div>&gt;</div>
        <div className="detail">详情</div>
      </div>

      <div className="hr"></div>

      <div className="context-box">
        <div className="context">
          <div className="name">{state.state.sname}</div>

          <div className="tr">
            <div className="td1">性别</div>
            <div>{state.state.ssex}</div>
          </div>
          <div className="tr">
            <div className="td">出生年月</div>
            <div>{toDate(state.state.sborn)}</div>
          </div>
          <div className="tr">
            <div className="td">身份证号</div>
            <div>{state.state.sidentity}</div>
          </div>
          <div className="tr">
            <div className="td">就读学校</div>
            <div>{state.state.sschool}</div>
          </div>
          <div className="tr">
            <div className="td">就读年级</div>
            <div>{state.state.sgrade}</div>
          </div>
          <div className="tr">
            <div className="td">培训课程</div>
            <div>{state.state.scourse}</div>
          </div>
          <div className="tr">
            <div className="td">培训学校</div>
            <div>{state.state.sinstitution}</div>
          </div>
          <div className="tr">
            <div className="td">备案家长</div>
            <div>{state.state.sparents}</div>
          </div>
          <div className="tr">
            <div className="td">备案时间</div>
            <div>{toTime(state.state.stime)}</div>
          </div>
        </div>
      </div>
    </div>
  );
};
export default StudentDetail;
